package com.AAL.DAO;

import org.hibernate.HibernateException;
import org.hibernate.classic.Session;

import com.AAL.Model.PriceOfProductInStock;
import com.AAL.Model.RequestingForCoordinator;
import com.AAL.Model.WheelDetail;
import com.AAL.Utils.HibernateUtil;

public class PriceOfProductInStockDAO {
	
	
	public PriceOfProductInStock getPriceOfProductInStockByWheelDetailID(String WheelDetailID) {
		try {
			/*Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.beginTransaction();
			PriceOfProductInStock priceOfProductInStock = (PriceOfProductInStock) session.load(WheelDetail.class, WheelDetailID);
			return priceOfProductInStock;*/
			
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.beginTransaction();
			PriceOfProductInStock priceOfProductInStock = null;		
		
			priceOfProductInStock = (PriceOfProductInStock) session.createQuery(
						"from PriceOfProductInStock where wheelDetail.wheelDetailID=:wheelDetailID")
						.setParameter("wheelDetailID",WheelDetailID).uniqueResult()	;	
			
			session.getTransaction().commit();
			return priceOfProductInStock;
			
		} catch (Exception e) {
			// TODO: handle exception
			System.out.println("Loi ham getPriceOfProductInStockByWheelDetailID:"+e.getMessage());
			return null;
		}
	}
}

